< previous page page_423 next page >

Page 423
To see that this transformation matrix works, multiply a generic point (x, y, z) by the generic translation matrix.
e10a6a0a59f035e870d90cca05b85fce.gif
 z0443-01.gif
The result, (x + Tx, y + Ty, z + Tz), is the correct translation of the point (x, y, z).
To make translation easy in Visual Basic, you can write a routine that initializes the entries in a transformation matrix to represent translation. This routine calls subroutine m3Identity to initialize the matrix to the identity matrix. It then sets the three entries needed for translation.
e10a6a0a59f035e870d90cca05b85fce.gif
' Create a 3-D transformation matrix for
' translation by Tx, Ty, and Tz.
Public Sub m3Translate(M() As Single, _
    Tx As Single, Ty As Single, Tz As Single)
Dim i As Integer

    m3Identity M()
    M(4, 1) = Tx
    M(4, 2) = Ty
    M(4, 3) = Tz
End Sub
Scaling
Three-dimensional scaling also generalizes easily from two dimensions. To scale a point by a factor of Sx in the X direction, Sy in the Y direction, and Sz in the Z direction, multiply the point by the matrix:
e10a6a0a59f035e870d90cca05b85fce.gif
 z0443-02.gif
You can verify that this matrix properly represents scaling by multiplying it by the point (x, y, z).
e10a6a0a59f035e870d90cca05b85fce.gif
 z0443-03.gif
The following code shows a routine that initializes scaling transformation matrices.

 
< previous page page_423 next page >